<%@ include file="../system/HeaderStrutsForm.jsp" %>
<html>
  <head>

    <bean:message key="page.css"/>
    <bean:message key="page.script"/>
  </head>
  <center>
    <body>
      <table class="mainTable" style='width:99%;'>
        <tr>
          <td>
            <html:form 
                action="Acesso/UrlForm.do"
                method="POST"
                styleClass="baseForm">

              <table class="bannerTable" style='width:99%;'>
                <tr>
                  <td class=tableHeader>
                    Cadastro de URL
                  </td>
                </tr>
              </table>
              <table class="messageTable" style='width:99%;'>
                <tr>
                  <td class="messageHeader">
                    <bean:message key="div.campos*"/>
                    <html:errors/>
                  </td>
                </tr>
              </table>
              <table class="itemTable" style='width:99%;'>
                <tr>
                  <td class="formLabel">
                    <span class="spamFormLabel" >
                      Url Path
                      <img 
                          src='../img/required.gif'
                          border='0'
                          alt='Not Null'
                          style='cursor:hand'>


                      &nbsp;
                    </span>
                  </td>
                  <td class="formField">
                    <html:text 
                        property="url_path"
                        styleClass="baseField"
                        size="50"
                        maxlength="255"/>
                  </td>
                </tr>
              </table>
              <table class="buttonTable" style='width:99%;'>
                <tr>
                  <td class="buttonItem">
                    <html:submit 
                        accesskey="i"
                        styleClass="baseButton"
                        property="insert_action">


                      <bean:message 
                          bundle="ApplicationResources"
                          key="jsp.insert"/>
                    </html:submit>
                    <html:submit 
                        accesskey="r"
                        styleClass="baseButton"
                        property="resetfull_action">


                      <bean:message 
                          bundle="ApplicationResources"
                          key="jsp.reset"/>
                    </html:submit>
                  </td>
                </tr>
              </table>
            </html:form>

            <%
            {
              %>
              <form class="baseForm" >
                <table class="bannerTable" style=width:99%;>
                  <tr>
                    <td class="tableHeader">
                      Lista de URLs
                    </td>
                  </tr>
                </table>
                <table 
                    id="TRbl_report_Url"
                    class="reportTable"
                    style=width:99%;
                     >

                  <%
                  int counterbl_report_Url=0;
                  %>
                  <%
                  {
                    br.com.werp.suporte.dbobj.table.Url t_url = new br.com.werp.suporte.dbobj.table.Url();
                    java.util.Vector res_Url = null;
                    com.egen.util.jdbc.JdbcUtil j = null;
                    try {
                      j = new com.egen.util.jdbc.JdbcUtil();
                      String[][] select =  null;
                      Object[][] where = null;
                      String[] groupby =  null;
                      String[] having =  null;
                      String[] order = {"url_path"};
                      res_Url = j.select(t_url,select,where,groupby,having,order);
                    } catch (Exception e){
                      session.setAttribute("exception",com.egen.util.system.Error.getDescription(e));
                      %>
                      <jsp:forward page="/system/ErrorPage.jsp"/>
                      <%
                    } finally {
                    if(j!=null){j.close();}
                  }
                  if (res_Url!=null && res_Url.size()>0) {
                    if ( ((String)request.getParameter("_ordered"))!=null && ((String)request.getParameter("_ordered")).length()>0 ) {
                      boolean reverse = false;
                      if ( ((String)request.getParameter("_reverse"))!=null && ((String)request.getParameter("_reverse")).length()>0 && ((String)request.getParameter("_reverse")).equals("true") ){
                        reverse = true;
                      }
                      try {
                        res_Url = com.egen.util.text.Sort.execute(res_Url,((String)request.getParameter("_ordered")),reverse);
                      } catch (Exception e) {}
                    }
                    int url_id =  0;
                    java.lang.String url_path =  null;
                    int i_bl_report_Url = 0;
                    t_url = (br.com.werp.suporte.dbobj.table.Url)res_Url.elementAt(i_bl_report_Url);
                    url_id = t_url.getUrl_id();
                    url_path = t_url.getUrl_path()==null?"":t_url.getUrl_path();
                    %>
                    <tr class="reportHeader" >
                      <td >
                        <span 
                            class="spamHeaderLabel"
                            style="text-align:left;width:100%;">

                          URL Path
                        </span>
                      </td>
                    </tr>
                    <%
                    while (i_bl_report_Url<res_Url.size()){
                      counterbl_report_Url++;
                      String style="";
                      if (!((i_bl_report_Url%2)!=0)) {
                        style="class=rowColor";
                      } else {
                        style="class=rowBlank";
                      }
                      %>
                      <tr 
                          <%=
                          style
                          %>
                          id='TRbl_report_Url<%=counterbl_report_Url%>'
                      >

                        <td class="reportcolumn"  >
                          <a 
                              href="../Acesso/UrlDetalheForm.do?select_action=&url_id=<%= url_id %>&url_path=<%= url_path %>"
                              target="_self"
                              STYLE="cursor:hand">


                            <span 
                                class="spamColumnLabel"
                                style="text-align:left;">

                              <%= url_path %>
                            </span>
                          </a>
                        </td>
                      </tr>
                      <%
                      if (++i_bl_report_Url >= res_Url.size()) {
                        break;
                      }
                      t_url = (br.com.werp.suporte.dbobj.table.Url)res_Url.elementAt(i_bl_report_Url);
                      url_id = t_url.getUrl_id();
                      url_path = t_url.getUrl_path()==null?"":t_url.getUrl_path();
                    }
                  }
                }
                %>
              </table>
            </form>
            <%
          }
          %>
        </td>
      </tr>
    </table>
  </body>
</center>
</html>
